/*****************************************************************************
//  File Name    : avrclock.c
//  Version      : 1.0
//  Description  : DS1307 RTC AVR Microcontroller Clock
//  Author       : RWB
//  Target       : AVRJazz Mega168 Board
//  Compiler     : AVR-GCC 4.3.0; avr-libc 1.6.2 (WinAVR 20080610)
//  IDE          : Atmel AVR Studio 4.14
//  Programmer   : AVRJazz Mega168 STK500 v2.0 Bootloader
//               : AVR Visual Studio 4.14, STK500 programmer
//  Last Updated : 28 April 2009
*****************************************************************************/

#include <avr/io.h>

#define F_CPU 3686400
#include <util/delay.h>


#include "i2cDriver.h"
#include "ds1307Driver.h"



int main(void)
{

	DDRD = 0xFF;                 // Set PORTD as Output
	PORTD = 0x00;	

	unsigned char h,m,s;

	rtcInit(); // Initialize the RTC
	_delay_ms(10);

	rtcSetTime(0x19,0x25,0x55); // Set RTC time

	_delay_ms(10);

	while(1)
	{

		rtcGetTime(&h,&m,&s); // Get time

		PORTD = bcdToDec(s & 0x7f); // Convert to bcd and assign to PORTD

		_delay_ms(1000);

	}
	
	return 0;
}



